package com.foot.travel.adapter;

import java.util.List;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView.LayoutParams;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.foot.travel.MyImageLoadingListener;
import com.foot.travel.R;
import com.koalac.ironman.net.pojo.response.GalleryPicture;
import com.koalac.ironman.util.ScreenInfoUtil;
import com.koalac.ironman.widget.ImageLoadAgreement.ImageType;
import com.koalac.ironman.widget.LifeqImageView;
import com.nostra13.universalimageloader.core.ImageLoader;

public class ImageAdapter extends BaseAdapter {

   List<GalleryPicture> photoUrls;
    LayoutInflater mInflater;
    Context mContext;
    int mItemWidth;

    public ImageAdapter(Context context, List<GalleryPicture> photoUrls,int itemWidth) {
	mInflater = LayoutInflater.from(context);
	this.photoUrls = photoUrls;
	mContext = context;
	mItemWidth = itemWidth;
    }
    

    @Override
    public int getCount() {
	return photoUrls.size();
    }

    @Override
    public Object getItem(int position) {
	return photoUrls.get(position);
    }

    @Override
    public long getItemId(int position) {
	return position;
    }


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
    	ImageView imageView;
	if (convertView == null) {
	    imageView = (ImageView) mInflater.inflate(R.layout.picture_item, null);
	}else{
		imageView = (ImageView) convertView;
	}
	LayoutParams lp = new LayoutParams(mItemWidth,mItemWidth);
	imageView.setLayoutParams(lp);
	Glide
	    .with(mContext)
	    .load(photoUrls.get(position).getPicurl())
	    .placeholder(R.drawable.ic_empty)
	    .crossFade()
	    .into(imageView);
	return imageView;
    }

}
